﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using DotNetNuke;
using DotNetNuke.Common;
using DotNetNuke.Common.Utilities;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.Localization;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Security.Roles;

namespace dnnTimeline.DesktopModules.dnnTimeline {
    public partial class TimelineSettings : DotNetNuke.Entities.Modules.ModuleSettingsBase
    {
        protected void Page_Load(object sender, EventArgs e) {
            if(!Page.IsPostBack)
            {
                if(ModuleSettings.ContainsKey("Height"))
                {
                    double height = (double)base.ModuleSettings["Height"];
                    this.HeightTextbox.Text = height.ToString() ;
                }
                if(ModuleSettings.ContainsKey("RSS"))
                {
                    string rss = (string)base.ModuleSettings["RSS"];
                    this.RSSTextBox.Text = rss;
                }
            }
        }

        protected void Button1_Click(object sender, EventArgs e) {
            if(this.HeightTextbox.Text != "") {
                double height = 0;
                string text = this.HeightTextbox.Text;
                if(double.TryParse(text, out height) && height > 0) {
                    ModuleSettings["Height"] = height;
                }
            }
            if(this.RSSTextBox.Text != "")
            {
                ModuleSettings["RSS"] = this.RSSTextBox.Text;
            }

            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
        }

        protected void Button2_Click(object sender, EventArgs e) {
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
        }
    }
}